package com.ocom.accesservice.controller;


import com.ocom.accesservice.service.AttendanceRulesService;
import com.ocom.common.constant.AccessServiceUrl;
import com.ocom.common.entity.access.EntityAttendanceRules;
import com.ocom.common.enums.ResultEnum;
import com.ocom.common.request.access.GetAttendanceRulesInfoReq;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Slf4j
@RestController
public class AttendanceRulesController {

    @Autowired
    AttendanceRulesService attendanceRulesService;



    @PostMapping(AccessServiceUrl.Url_attendanceRulesList)
    public Result<List<EntityAttendanceRules>> getAttendanceRuleList(@RequestBody GetAttendanceRulesInfoReq request) {
        List<EntityAttendanceRules> list = attendanceRulesService.getAttendanceRulesList(request.getComId(), request);
        if (list == null || list.size()==0) {
            return ResultUtil.error(ResultEnum.Err_1001);
        }
        return ResultUtil.success(list);
    }

}
